{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "from autogen_agentchat.agents import AssistantAgent\n",
    "from autogen_core.models import UserMessage\n",
    "from autogen_ext.models.azure import AzureAIChatCompletionClient\n",
    "from azure.core.credentials import AzureKeyCredential\n",
    "from autogen_core import CancellationToken\n",
    "\n",
    "from autogen_agentchat.messages import TextMessage\n",
    "from autogen_agentchat.ui import Console\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "finish_reason='stop' content='The capital of France is Paris.' usage=RequestUsage(prompt_tokens=14, completion_tokens=7) cached=False logprobs=None thought=None\n"
     ]
    }
   ],
   "source": [
    "client = AzureAIChatCompletionClient(\n",
    "    model=\"gpt-4o-mini\",\n",
    "    endpoint=\"https://models.inference.ai.azure.com\",\n",
    "    # To authenticate with the model you will need to generate a personal access token (PAT) in your GitHub settings.\n",
    "    # Create your PAT token by following instructions here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens\n",
    "    credential=AzureKeyCredential(os.environ[\"GITHUB_TOKEN\"]),\n",
    "    model_info={\n",
    "        \"json_output\": True,\n",
    "        \"function_calling\": True,\n",
    "        \"vision\": True,\n",
    "        \"family\": \"unknown\",\n",
    "    },\n",
    ")\n",
    "\n",
    "result = await client.create([UserMessage(content=\"What is the capital of France?\", source=\"user\")])\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "agent = AssistantAgent(\n",
    "    name=\"assistant\",\n",
    "    model_client=client,\n",
    "    tools=[],\n",
    "    system_message=\"You are a travel agent that plans great vacations\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n",
      "source='assistant' models_usage=RequestUsage(prompt_tokens=26, completion_tokens=646) content=\"Absolutely! Here’s a sunny vacation plan that combines relaxation, adventure, and cultural experiences. Let’s set you up for a week in beautiful Costa Rica!\\n\\n### Destination: Costa Rica\\n\\n#### Duration: 7 Days\\n\\n#### Ideal Travel Time: December to April (dry season)\\n\\n---\\n\\n### Day 1: Arrival in San José\\n- **Flight:** Arrive at Juan Santamaría International Airport (SJO).\\n- **Accommodation:** Check into a trendy hotel in the Escazú or downtown San José.\\n- **Evening:** Enjoy dinner at a local restaurant featuring Costa Rican cuisine. Try “casado” (rice and beans with protein).\\n\\n---\\n\\n### Day 2: Arenal Volcano\\n- **Morning:** Travel to La Fortuna (about 3 hours from San José).\\n- **Accommodation:** Stay in a resort with views of Arenal Volcano.\\n- **Afternoon:** Visit the La Fortuna Waterfall for a refreshing swim.\\n- **Evening:** Relax in the hot springs at Tabacon or Baldi.\\n\\n---\\n\\n### Day 3: Arenal Adventure\\n- **Morning:** Zip-lining through the rainforest canopy at Sky Adventures.\\n- **Afternoon:** Hike in Arenal Volcano National Park for stunning views and rich biodiversity.\\n- **Evening:** Dine at a local restaurant with a view of the volcano.\\n\\n---\\n\\n### Day 4: Monteverde Cloud Forest\\n- **Morning:** Travel to Monteverde (about 3.5 hours).\\n- **Accommodation:** Stay in a charming lodge surrounded by nature.\\n- **Afternoon:** Explore the Monteverde Cloud Forest Reserve, with opportunities for bird watching and spotting wildlife.\\n- **Evening:** Enjoy a guided night walk to see nocturnal creatures.\\n\\n---\\n\\n### Day 5: Relaxation and Beaches\\n- **Morning:** Depart for Manuel Antonio (around 3 hours).\\n- **Accommodation:** Settle into a beach resort with ocean views.\\n- **Afternoon:** Relax on the beach or at the hotel pool.\\n- **Evening:** Dinner at a beachfront restaurant.\\n\\n---\\n\\n### Day 6: Manuel Antonio National Park\\n- **Morning:** Guided tour of Manuel Antonio National Park to see sloths, monkeys, and stunning beaches.\\n- **Afternoon:** Snorkeling or kayaking in the nearby waters.\\n- **Evening:** Take a sunset sailboat tour (with refreshments) for beautiful views of the coastline.\\n\\n---\\n\\n### Day 7: Return to San José\\n- **Morning:** Leisurely breakfast, then head back to San José (about 3 hours).\\n- **Afternoon:** Last-minute shopping at a local artisan market or visit the National Museum.\\n- **Evening:** Departure from Juan Santamaría International Airport.\\n\\n---\\n\\n### Additional Tips:\\n- **Travel Insurance:** Consider purchasing travel insurance for peace of mind.\\n- **Local Currency:** Keep some Costa Rican colones handy for local vendors.\\n- **Transportation:** Renting a car can provide flexibility for exploring, but shuttles are also readily available.\\n\\nThis Costa Rican itinerary has a perfect blend of sun-soaked beach time, lush rainforest adventures, and cultural experiences to make it an unforgettable vacation. Let me know if you'd like to customize any part of this plan!\" type='TextMessage'\n"
     ]
    }
   ],
   "source": [
    "async def assistant_run() -> None:\n",
    "    response = await agent.on_messages(\n",
    "        [TextMessage(content=\"Plan me a great sunny vacation\", source=\"user\")],\n",
    "        cancellation_token=CancellationToken(),\n",
    "    )\n",
    "    print(response.inner_messages)\n",
    "    print(response.chat_message)\n",
    "\n",
    "\n",
    "# Use asyncio.run(assistant_run()) when running in a script.\n",
    "await assistant_run()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
